package 数组.easy;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @author Lw中
 * @date 2020/8/14 11:02
 */
public class SiSiBa {

    public static List<Integer> findDisappearedNumbers(int[] nums) {
        ArrayList<Integer> arrayList = new ArrayList<>();
        int[] arr = new int[nums.length+1];
        for (int i = 0; i < nums.length; i++) {
            arr[nums[i]]++;
        }
        for (int i = 1; i < arr.length; i++) {
            if (arr[i] == 0) {
                arrayList.add(i);
            }
        }
        return arrayList;
    }

    public static void main(String[] args) {
        int[] arr = {4,3,2,7,8,2,3,1};
        List<Integer> disappearedNumbers = findDisappearedNumbers(arr);
        Iterator<Integer> iterator = disappearedNumbers.iterator();
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }

}
